package edu.hz.controller;


import edu.hz.model.dto.DonationHoleListContentDto;
import edu.hz.model.dto.DonationHoleListDto;
import edu.hz.service.DonationService;
import edu.hz.util.web.ApiResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin(origins = "*")
@RestController
public class DonationController {

    @Resource
    DonationService donationService;

    @GetMapping("/donation/hole-list")
    public ApiResponse<List<DonationHoleListDto>> holeList() {
        return donationService.allDonations();
    }

    @GetMapping("/donation/info")
    public ApiResponse<DonationHoleListContentDto> getById(@RequestParam("id") Integer donationId) {
        return ApiResponse.success(donationService.donationInfo(donationId));
    }

}
